package com.gcq.javawork.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gcq.javawork.common.Result;
import com.gcq.javawork.model.domain.Goods;
import com.gcq.javawork.service.GoodsService;
import com.gcq.javawork.mapper.GoodsMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.swing.text.html.Option;
import java.util.List;
import java.util.Optional;

/**
* @author guochuqu
* @description 针对表【goods(商品表)】的数据库操作Service实现
* @createDate 2024-10-16 16:37:51
*/
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods>
    implements GoodsService{

    @Resource
    private  GoodsMapper goodsMapper;

    @Override
    public List<Goods> searchGoods(String goodsName) {

        return  goodsMapper.selectList(new QueryWrapper<Goods>().like("goods_name", goodsName));
    }

    @Override
    public void insertGoods(Goods goods) {
        if (goods == null){
            throw new RuntimeException("商品信息不能为空");
        }
        save(goods);
    }

    @Override
    public void updateGoods(Goods goods) {
        updateGoods(goods);

    }

    @Override
    public Boolean deleteGoods(Long goodsId) {
        if (goodsId == null){
            return false;
        }
         removeById(goodsId);

        return true;
    }


}




